import js from '@eslint/js';
import { defineFlatConfig } from 'eslint-define-config';
import pluginVue from 'eslint-plugin-vue';
import vueParser from 'vue-eslint-parser';

export default defineFlatConfig([
    {
        ignores: [
            'node_modules/**',
            'dist/**',
            'public/**'
        ]
    },
    js.configs.recommended,
    ...pluginVue.configs['flat/recommended'],
    {
        languageOptions: {
            ecmaVersion: 'latest',
            sourceType: 'module',
            globals: {
                window: 'readonly',
                document: 'readonly',
                localStorage: 'readonly',
                console: 'readonly',
                CustomEvent: 'readonly',
                module: 'readonly',
                ThemeManager: 'writable'
            }
        },
        rules: {
            'indent': ['error', 4],
            'vue/html-indent': ['error', 4],
            'vue/script-indent': ['error', 4],
            'vue/multi-word-component-names': 'off',
            'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
            'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
            // 移除@typescript-eslint相关规则
        },
    },
    {
        files: ['**/*.vue'],
        rules: {
            'indent': 'off',
        },
        languageOptions: {
            parser: vueParser,
            parserOptions: {
                // 移除typescript解析器
                extraFileExtensions: ['.vue'],
                ecmaFeatures: {
                    jsx: true
                }
            }
        }
    },
]);